package com.qst.mapreduce.wordcount.diliuzhang.zuoye.mywc;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class MyWordCountMapper extends Mapper<LongWritable, Text, Text, IntWritable> {

    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, IntWritable>.Context context) throws IOException, InterruptedException {
        String line=value.toString();
        //数据的转化
        String[] words=line.split(" ");
        //拆分成数组
        for (String word:words) {
            Text outkey=new Text(word);
            IntWritable outvalue=new IntWritable(1);
            context.write(outkey, outvalue);
        }






    }
}
